package com.archermind.boc;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;

public class Logger {
	private static FileHandler handler;

	static {
		try {
			handler = new FileHandler("boc%g.log",1000*1000*5,30,true);
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		handler.setFormatter(new BocLogFormatter());
	}

	private java.util.logging.Logger l;

	private Logger(String name) {
		l = java.util.logging.Logger.getLogger(name);
		l.addHandler(handler);
	}

	public static Logger getLogger(String name) {
		return new Logger(name);
	}

	public void info(String message) {
		l.info(message);
	}

	public void warning(String msg) {
		l.warning(msg);
	}

	public void warning(String msg, Exception e) {
		l.log(Level.WARNING, msg, e);
	}

	public void severe(String msg) {
		l.severe(msg);
	}

	public void error(String msg) {
		l.severe(msg);
	}

	public void error(String message, Exception e) {
		l.log(Level.SEVERE, message, e);
	}
}
